import java.util.ArrayList;
import java.util.List;

public class SolutionOfferII41 {

    int size;
    int sum;
    List<Integer> list=new ArrayList<>();

    public SolutionOfferII41(int size) {
        this.size=size;
    }

    public double next(int val) {
        list.add(val);
        sum+=val;
        if (list.size()>size){
            sum-=list.get(0);
            list.remove(0);
        }
        return (double)sum/list.size();
    }

    public static void main(String[] args) {
        SolutionOfferII41 solutionOfferII41=new SolutionOfferII41(3);
        System.out.println(solutionOfferII41.next(1));
        System.out.println(solutionOfferII41.next(10));
        System.out.println(solutionOfferII41.next(3));
        System.out.println(solutionOfferII41.next(5));
    }
}
